﻿using System.Diagnostics;

namespace LFSRecord2.Model.UserActions
{
    public class UserActionLayerNameChanged : UserActionBase
    {
        // Action description, so we can replay this action (and reverse it)
        public CompLayerTypes LayerType { get; set; }
        public int LayerIndex { get; set; }
        public string OldName { get; set; }
        public string NewName { get; set; }

        public UserActionLayerNameChanged()
        {
            Action = UserActionTypes.LayerNameChanged;
        }

        public override void DoUndo()
        {
            Debug.WriteLine("Undoing a LayerNameChanged action");
            if (LayerType == CompLayerTypes.Audio)
                LfsRecordController.project.AudioLayers[LayerIndex].LayerName = OldName;
            else
                LfsRecordController.project.Layers[LayerIndex].LayerName = OldName;
        }

        public override void DoRedo()
        {
            Debug.WriteLine("Redoing a LayerNameChanged action");
            if (LayerType == CompLayerTypes.Audio)
                LfsRecordController.project.AudioLayers[LayerIndex].LayerName = NewName;
            else
                LfsRecordController.project.Layers[LayerIndex].LayerName = NewName;
        }
    }
}
